﻿using System;
using System.Linq;

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Derbster.Domain.Test
{
    [TestClass]
    public class PenaltyUnitTest : ContractUnitTest
    {
        [TestMethod]
        public void TestCreate()
        {
            var testMatch = TestHelper.CreateTestMatch(true, true);

            var penalty = new Penalty(testMatch, testMatch.FirstTeamRoster.First(), "B", 1, 1, 1);
            Assert.IsNotNull(penalty);
        }


        [TestMethod]
        public void TestEquals()
        {
            var newPenalty = new Penalty();
            Assert.IsTrue(newPenalty.Equals(newPenalty));
        }

        [TestMethod]
        public void TestCreateBadCode()
        {
            var testMatch = TestHelper.CreateTestMatch(true, true);
            bool throws = false;
            try
            {
                var penalty = new Penalty(testMatch, testMatch.FirstTeamRoster.First(), "W", 1, 1, 1);

            }
            catch (Exception)
            {
                throws = true;
            }
           
            Assert.IsTrue(throws);
        }
        [TestMethod]
        public void TestCreateBadPeriod()
        {
            var testMatch = TestHelper.CreateTestMatch(true, true);
            bool throws = false;
            try
            {
                var penalty = new Penalty(testMatch, testMatch.FirstTeamRoster.First(), "B",3, 1, 1);

            }
            catch (Exception)
            {
                throws = true;
            }

            Assert.IsTrue(throws);
        }
        [TestMethod]
        public void TestCreateBadJam()
        {
            var testMatch = TestHelper.CreateTestMatch(true, true);
            bool throws = false;
            try
            {
                var penalty = new Penalty(testMatch, testMatch.FirstTeamRoster.First(), "B", 3, -1, 1);

            }
            catch (Exception)
            {
                throws = true;
            }

            Assert.IsTrue(throws);
        }




    }
}
